package com.cskaoyan.day24.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.Scanner;

public class Sender {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        DatagramSocket datagramSocket = new DatagramSocket(9999);

        while (true) {
            DatagramPacket sendPacket = UDPUtils.getSendPacket(sc.nextLine(), "127.0.0.1", 8888);
            datagramSocket.send(sendPacket);

            DatagramPacket receivePacket = UDPUtils.getReceivePacket();
            datagramSocket.receive(receivePacket);
            UDPUtils.parseSendData(receivePacket);
        }


    }
}
